//获取当前路径
function getNowPath(){
	var last=location.href.lastIndexOf("/");
	return location.href.substring(0,last);
}

//发送消息
function send(method, url, ajax, data, accessFunc, faultFunc) {
	var xmlhttp;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	} else {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if(url.indexOf(':')>=0){
		var uri=url;
	}else{
		var uri=getNowPath()+url;
	}
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			if(xmlhttp.status == 200 && accessFunc!=null){
				try{
					accessFunc(xmlhttp.responseText);
				}catch(e){
					rat.pushInfo("异步处理发生异常，请检查一下网络连接是不是出问题了！");
				}
			}else if(Math.floor(xmlhttp.status/100)==3){
				//
			}else if(Math.floor(xmlhttp.status/100)==4 && faultFunc!=null){
				faultFunc(xmlhttp.status);
			}else if(Math.floor(xmlhttp.status/100)==5 && faultFunc!=null){
				faultFunc(xmlhttp.status);
			}
		}
	}
	xmlhttp.open(method, uri, ajax);
	xmlhttp.send(data);
}
